const { findShop, inserShop } = require("../model/shop");
const getAllShop = (req, resp) => {
  findShop()
    .then(list => {
      resp.json({
        code: 200,
        body: {
          list
        }
      });
    })
    .catch(err => {
      esp.json({
        code: 400,
        body: {
          err
        }
      });
    });
  //   resp.send("list555555");
};
//新增一条数据
const addShop = (req, resp) => {
  const { name, price, num } = req.query;
  console.log(req.addShop);
  inserShop({ name, price, num })
    .then(shop => {
      resp.json({
        code: 200,
        body: {
          msg: "新增信息成功",
          shop
        }
      });
    })
    .catch(err => {
      resp.json({
        code: 400,
        body: {
          msg: "网络错误",
          shop
        }
      });
    });
};
module.exports = {
  getAllShop,
  addShop
};
